public class ArrayRotation
{
	public static void main(String[] args){
		
		int[] array = new int[] {1,2,3,4,5,6,7,8,9,10};
		
		System.out.println("*********************Right Rotation*********************");
		System.out.println("");
		printRightRotatedArray(array,2);
		System.out.println("*********************Left Rotation*********************");
		System.out.println("");		
		printLeftRotatedArray(array,2);
	}
	
	public static void printRightRotatedArray(int[] array, int rotation){
			int rotatedIndex = 0;
			int n = array.length;
		for(int i = 0; i < array.length; i++) {
			rotatedIndex = (i + (rotation%n))%n;
			System.out.println(array[rotatedIndex]);
		}
	}
	public static void printLeftRotatedArray(int[] array, int rotation){
			int rotatedIndex = 0;
			int n = array.length;
		for(int i = 0; i < array.length; i++) {
			rotatedIndex = (i + (n - (rotation % n)))%n;
		/*	if(rotatedIndex >= array.length){
			
				rotatedIndex = rotatedIndex % array.length;
			} */
			System.out.println(array[rotatedIndex]);
		}
	}
}